<?php

namespace App\Model;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class Home extends BaseModel
{
    protected $table = 'home';
    public $timestamps = true;

    public function getHomeList(Request $request){
        $limit = $request->input('limit',10);
        $page = $request->input('page',1);
        $channel_id = $request->input('channel_id','');
        $query = DB::connection($this->connection)->table($this->table);
        if ($channel_id) $query->where('channel_id',intval($channel_id));
        return $query->paginate($limit, '*','page',$page);
    }

    //更新
    public function addOrupdateData($data)
    {
        return curl_request(getKkaudioApiUrl() . '/inner/home/upsert', $data, 'json', 'POST');
    }
    public function delData($data){
        return curl_request(getKkaudioApiUrl() . '/inner/home/delHome', $data, 'json', 'POST');
    }

}
